/* lwipopts.h — minimal NO_SYS (no RTOS) config for unix/tap.
 * Focus: IPv4 + Ethernet + ICMP + TCP/UDP, raw API, no sockets/netconn.
 */

#ifndef LWIPOPTS_H
#define LWIPOPTS_H

/* --- System --- */
#define NO_SYS                          1
#define SYS_LIGHTWEIGHT_PROT            0
#define LWIP_TIMERS                     1
#define LWIP_MPU_COMPATIBLE             0

#define LWIP_HTTPD_CGI               1          // 开 CGI（GET/查询串）
#define LWIP_HTTPD_SUPPORT_POST      1          // 开 POST 钩子
#define LWIP_HTTPD_MAX_REQ_LENGTH    1024       // 够解析请求行/头
#define LWIP_HTTPD_MAX_URI_LEN       128

// 为了返回“动态内容”（不用落盘文件）：
#define LWIP_HTTPD_CUSTOM_FILES      1          // 允许自定义打开某些“虚拟文件”
#define LWIP_HTTPD_DYNAMIC_FILE_READ 1          // 允许分块读取我们构造的内存数据
#define LWIP_HTTPD_FILE_STATE             1     // 开启 file->state
#define LWIP_HTTPD_FILE_FLAGS             1     // 开启 file->flags（含 HEADER_INCLUDED 宏）
#define LWIP_HTTPD_SUPPORT_V09       0
#define LWIP_HTTPD_DYNAMIC_HEADERS   1

/* --- Memory --- */
#define MEM_ALIGNMENT                   4
#define MEM_SIZE                        (32 * 1024)
#define MEMP_NUM_PBUF                   32
#define MEMP_NUM_RAW_PCB                4
#define MEMP_NUM_UDP_PCB                8
#define MEMP_NUM_TCP_PCB                8
#define MEMP_NUM_TCP_SEG                64
#define PBUF_POOL_SIZE                  32
#define PBUF_POOL_BUFSIZE               1700

/* --- Protocols --- */
#define LWIP_ARP                        1
#define LWIP_ETHERNET                   1

#define LWIP_IPV4                       1
#define LWIP_IPV6                       0

#define LWIP_ICMP                       1
#define LWIP_IGMP                       0

#define LWIP_RAW                        1
#define LWIP_UDP                        1
#define LWIP_TCP                        1

/* Disable high-level APIs (bare-metal style) */
#define LWIP_SOCKET                     0
#define LWIP_NETCONN                    0

/* --- DHCP/DNS (off for static config; enable if you need) --- */
#define LWIP_DHCP                       0
#define LWIP_DNS                        0

/* --- Debug & Stats (tune as needed) --- */
#define LWIP_DEBUG                      0
#define TCP_DEBUG                       0
#define IP_DEBUG                        0
#define ETHARP_DEBUG                    0
#define PBUF_DEBUG                      0

#define MEMP_OVERFLOW_CHECK             2
#define MEMP_SANITY_CHECK               1
#define MEM_OVERFLOW_CHECK              2
#define MEM_SANITY_CHECK                1

#define LWIP_STATS                      1
#define LWIP_STATS_DISPLAY              1

/* --- Checksum (let lwIP do it in software) --- */
#define LWIP_CHECKSUM_CTRL_PER_NETIF    0
#define CHECKSUM_GEN_IP                 1
#define CHECKSUM_GEN_UDP                1
#define CHECKSUM_GEN_TCP                1
#define CHECKSUM_GEN_ICMP               1
#define CHECKSUM_CHECK_IP               1
#define CHECKSUM_CHECK_UDP              1
#define CHECKSUM_CHECK_TCP              1
#define CHECKSUM_CHECK_ICMP             1

#endif /* LWIPOPTS_H */
